{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
    <link rel="stylesheet" type="text/css" href="/css/common/daterangepicker-bs3.css" />
    <link rel="stylesheet" type="text/css" href="/css/mediation/caseallocate/index.css" />
<style>
.modal.in .modal-dialog{
    transform: translate(0,50%)!important;
}
</style>
{/block}
{block name="page_section"}
	<div class="sessionPage">
    <div class="page-header">
      <div class="left">
        <span class="line"></span>
        <strong class="tit">修复记录</strong>
      </div>
    </div>
    <form class="small-style" method="get" action="" id="form-ele" role="validform" enctype="multipart/form-data">
      <div class="form_row">
        <input type="hidden" name="is_show" class="showmoreishow" value="{if $is_show == 1}1{else}0{/if}">
        <input type="hidden" name="limit" value="{if $query.limit}{$query.limit}{/if}">
        <div class="form-group col-lg-3 ui-select">
            <label class="col-sm-4 control-label">
                修复时间:
            </label>
            <div class="col-sm-7">
                <input data-ele="date" data-type="daterange" name="add_begin_end" class="form-control" placeholder="请选择" value="{if !empty($smarty.get.add_begin_end)}{$smarty.get.add_begin_end}{/if}" autocomplete="off"/>
            </div>
        </div>
        <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">修复运营商:</label>
            <div class="col-sm-7">
                <select class="form-control selectpicker"    title="请选择" name="repairType" id="repairType">
                    <option class="u144_input_option" {if !empty($query.repairType) &&  1 == $query.repairType}selected="selected"{/if} value="1">移动</option>
                    <option class="u144_input_option" {if !empty($query.repairType) &&  2 == $query.repairType}selected="selected"{/if} value="2">联通</option>
                </select>
            </div>
        </div>
        <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">修复姓名:</label>
            <div class="col-sm-7">
                <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.repairName)}{$query.repairName}{/if}" name="repairName" id="repairName" placeholder="请输入~">
            </div>
        </div>
        <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">运营商批次号:</label>
            <div class="col-sm-7">
                <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.batchNo)}{$query.batchNo}{/if}" name="batchNo" id="batchNo" placeholder="请输入~">
            </div>
        </div>
      </div>
      <div class="form_row">
          <div class="form-group col-lg-3 ui-select">
            <label for="exampleInputName2"  class="col-sm-4 control-label">修复身份证号:</label>
            <div class="col-sm-7">
                <input type="text" class="form-control noempty col-sm-4"  value="{if !empty($query.idCard)}{$query.idCard}{/if}" name="idCard" id="idCard" placeholder="请输入~">
            </div>
         </div>

          <div class="form-group col-lg-3 ui-select">
              <label for="exampleInputName2"  class="col-sm-4 control-label">号码状态:</label>
              <div class="col-sm-7">
                  <select class="form-control selectpicker"   title="请选择" name="mobileStatus" id="mobileStatus">
                      {foreach from=$mobileStatus key=key  item=info}
                      <option class="u144_input_option" {if !empty($query.mobileStatus) &&  $key == $query.mobileStatus}selected="selected"{/if} value="{$key}">{$info}</option>
                      {/foreach}
                  </select>
              </div>
          </div>
        <div class="form-group col-lg-3 ui-select">
            <div class="col-lg-5" style="float: right;">
                <button class="btn btn-primary col-lg-8 shousuoBtn "><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
            </div>
            <div class="col-lg-5">
                <a type="button" href="/repairrecord" class="btn btn-default col-lg-8 "><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
            </div>
            <div class="col-lg-5">
                <button   class="btn btn-info col-lg-8 data_upload"><span class="nav-icon glyphicon glyphicon-download-alt" aria-hidden="true" style="margin-right: 2px"></span>导出</button>
            </div>
        </div>
        <div class="ui-select"></div>
      </div>
    </form>
    <div style="width: 95%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow-x: scroll;">
        <table class=" table table-striped table-bordered table-hover text-nowrap" id="tab">
            <thead>
                <tr>
                    <th>运营商批次号</th>
                    <th>运营商</th>
                    <th>修复姓名</th>
                    <th>修复身份号</th>
                    <th>修复号码数</th>
                    <th>修复时间</th>
<!--                    <th>号码状态</th>-->
                    <th>有效期</th>
            </thead>
            <tbody>
                {foreach from=$arrList item=item name=foo}
                <tr>
                    <td>{if empty($item.batchNo)}--{else}{$item.batchNo}{/if}</td>
                    <td>{if $item.repairType == 1}移动{else}联通{/if}</td>
                    <td>{$item['repairName']}</td>
                    <td>{substr($item['idCard'] , 0 , 5)}******{substr($item['idCard'] , -4)}</td>
                    <td>{$item['num']}</td>
                    <td>{if empty($item.repairTime)}--{else}{$item.repairTime|date_format:"%Y-%m-%d %H:%M:%S"}{/if}</td>
<!--                    <td>{$mobileStatus[$item['mobileStatus']]}</td>-->
                    <td>{if $item.validityTime == 4000000000 }永久{else}{$item.validityTime|date_format:"%Y-%m-%d %H:%M:%S"}{/if}</td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
    <input type="hidden" value="" id="allocate_type">
    <input type="hidden" value="" id="allocate_ids">

    <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
        {include file="base/pagenav.html"  action="/repairrecord/index" pagenum=$curPageNum inline}
        <select class="form-control" id="paglimit" style="float:right;margin:0 10px;width: auto;margin-top: -5px;">
            <option value="limit=10" {if $query.limit==10}selected="selected"{/if}>10条/页</option>
            <option value="limit=20" {if $query.limit==20}selected="selected"{/if}>20条/页</option>
            <option value="limit=50" {if $query.limit==50}selected="selected"{/if}>50条/页</option>
            <option value="limit=100" {if $query.limit==100}selected="selected"{/if}>100条/页</option>
        </select>
        <span style="float:right;">共 {$totalnum} 条</span>
    </div>
{/block}
{block name="page_scripts"}
    <script type="text/javascript">
        $(".data_upload").on("click",function(){
            var is_down =confirm('请确认是否下载？\n'+ '下载时间可能比较慢,点击后请耐心等待!') ;
            if(is_down){
                $("#form-ele").attr('action','/repairrecord/exportinfo');
                $("#form-ele").submit();
            }

        });

        $(".caseallocateall").on("click",function(){
            var arrbtn = [];
            $(".j-check:checked").each(function (index, ele) {
                //遍历所有复选框，然后取值进行 !非操作
                if ($(this).prop("checked")) {
                    arrbtn.push($(this).val());
                }
            })
            if(arrbtn.length==0){
                toastr.error('请选择案件');
                return false;
            }
            var ids=arrbtn.toString();
            $("#allocate_ids").val(ids);
            $("#allocate_type").val($(this).attr('allocate-type'));

        });

        $(".caseallocateone").on("click",function(){
            var ids=$(this).attr('data-id');
            $("#allocate_ids").val(ids);
            $("#allocate_type").val(1);

        });
        function GetQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
        $('body')
            .on('change','#paglimit', function(){
            console.log()
            var mediationOrganId = GetQueryString('mediationOrganId');
            var paglimit = GetQueryString('limit');
            var val =  $(this).val();
            if(!mediationOrganId){
                if(!paglimit){
                    window.location = window.location.href+'?'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }else{
                if(!paglimit){
                    window.location = window.location.href+'&'+val;
                } else{
                    window.location = window.location.href.replace('limit='+paglimit,val);
                }
            }
        })
            .on('click','.confirmreapir', function(){
                var that=$(this);
                $.confirm({
                    title: '注意！',
                    content: '确认提交复联，完成后会对成功数据收费！',
                    confirmButton: '确定',
                    cancelButton: '取消',
                    confirm: function(){
                        $.ajax({
                            url:"/repairbatch/submitISP",
                            method:"post",
                            data:{
                                id: that.attr('data-id'),
                            },
                            success:function(res){
                                if(res.code==200){
                                    toastr.success("提交成功");
                                }else{
                                    toastr.error(res.message);
                                }
                                setTimeout(function(){
                                    window.location.reload();
                                },2000)
                            },
                            error: function(err){
                                toastr.error('网络错误,请稍后重试');
                            }
                        })
                    },
                    cancel: function(){
                        // alert('Canceled!')
                    }
                });
            })

    </script>
{/block}
